From afc1615946cd127d9ea28e0892934251c6a00a84 Mon Sep 17 00:00:00 2001
From: "Murray S. Kucherawy" <msk@trusteddomain.org>
Date: Sat, 4 Mar 2017 08:03:22 -0800
Subject: [PATCH] Fix bug #137: Handle base64 inside AR tokens that are values.
 Problem reported by Joseph Coffland.

---
 RELEASE_NOTES            |  2 ++
 opendmarc/opendmarc-ar.c | 14 +++++++++++++-
 2 files changed, 15 insertions(+), 1 deletion(-)

Index: opendmarc/RELEASE_NOTES
===================================================================
--- opendmarc.orig/RELEASE_NOTES	2018-12-17 01:38:44.570329334 -0500
+++ opendmarc/RELEASE_NOTES	2018-12-17 01:40:21.062333399 -0500
@@ -3,6 +3,10 @@
 This listing shows the versions of the OpenDMARC package, the date of
 release, and a summary of the changes in that release.
 
+ 1.4.0          2017/??/??
+        Fix bug #137: Handle base64 inside AR tokens that are values.
+                Problem reported by Joseph Coffland.
+
 1.3.2		2016/12/19
 	Feature request #86: Change meaning of "RequiredHeaders" such that
 		header validity is always checked, but messages are only
Index: opendmarc/opendmarc/opendmarc-ar.c
===================================================================
--- opendmarc.orig/opendmarc/opendmarc-ar.c	2018-12-17 01:38:44.570329334 -0500
+++ opendmarc/opendmarc/opendmarc-ar.c	2018-12-17 01:38:44.566329334 -0500
@@ -602,7 +602,19 @@
 			ar->ares_result[n - 1].result_props = r;
 
 			prevstate = state;
-			state = 9;
+			if (c < ntoks - 1 && tokens[c + 1][1] == '\0')
+			{
+				if (tokens[c + 1][0] == ';')
+					state = 2;
+				else if (tokens[c + 1][0] == '=')
+					r--;
+				else
+					state = 9;
+			}
+			else
+			{
+				state = 9;
+			}
 
 			break;
 		}
